<html>
<head>
    <meta charset="UTF-8">
    <title>添加任务</title>
    <!--<script type="application/javascript" src="js/jquery-1.11.3.min.js"></script>-->
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
    <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body onload="switchStore()">
<h2>添加在线购买监控</h2>

<div class="tabbable tabbable-custom tabbable-full-width">
    <ul class="nav nav-tabs">
        <li role="presentation" class="active"><a href="#onlineTask" data-toggle="tab">添加在线购买监视任务</a></li>
        <li role="presentation"><a href="#storeTask" data-toggle="tab">添加Store自提监视任务</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="onlineTask">
            <form id="addOnlineTaskForm" class="form-inline" method="post">
                <div class="form-group">
                    <label for="email">email(必填)</label>
                    <input class=".form-control" id="email" name="email" type="text">
                </div>
                <div class="form-group">
                    <label for="region">版本</label>
                    <select id="region" class=".form-control" name="region">
                        <option value="cn">国行</option>
                        <option value="hk">港行</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="IPhoneScreenSize">手机型号</label>
                    <select id="IPhoneScreenSize" class=".form-control"
                            name="IPhoneScreenSize">
                        <option value="4_7inch">6S</option>
                        <option value="5_5inch">6S Plus</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="IPhoneColor">手机颜色</label>
                    <select id="IPhoneColor" name="IPhoneColor">
                        <option value="space_gray">天空灰</option>
                        <option value="gold">土豪金</option>
                        <option value="silver">银色</option>
                        <option value="rosegld">玫瑰金</option>
                    </select>
                </div>
                <div class="form-group"><label for="IPhoneCapacity">手机容量</label>
                    <select id="IPhoneCapacity" name="IPhoneCapacity">
                        <option value="16gb">16GB</option>
                        <option value="64gb">64GB</option>
                        <option value="128gb">128GB</option>
                    </select>
                </div>
                <input type="button" class="btn btn-default" onclick="doSubmit(1)" value="提交">
            </form>
        </div>

        <div class="tab-pane" id="storeTask">
            <form id="addStoreTaskForm" class="form-inline" method="post">
                <div class="form-group">
                    <label for="storeEmail">email(必填)</label>
                    <input class=".form-control" id="storeEmail" name="email" type="text">
                </div>
                <div class="form-group">
                    <label for="storeRegion">版本</label>
                    <select id="storeRegion" class=".form-control" name="region" onchange="switchStore()">
                        <option value="cn">国行</option>
                        <option value="hk">港行</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="storeIPhoneScreenSize">手机型号</label>
                    <select id="storeIPhoneScreenSize" class=".form-control"
                            name="IPhoneScreenSize">
                        <option value="4_7inch">6S</option>
                        <option value="5_5inch">6S Plus</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="storeIPhoneColor">手机颜色</label>
                    <select id="storeIPhoneColor" name="IPhoneColor">
                        <option value="space_gray">天空灰</option>
                        <option value="gold">土豪金</option>
                        <option value="silver">银色</option>
                        <option value="rosegld">玫瑰金</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="storeIPhoneCapacity">手机容量</label>
                    <select id="storeIPhoneCapacity" name="IPhoneCapacity">
                        <option value="16gb">16GB</option>
                        <option value="64gb">64GB</option>
                        <option value="128gb">128GB</option>
                    </select>
                </div>
                <div id="cnStore">
                    <label><input name="storeNO" type="checkbox" value="R320">北京-西单大悦城</label>
                    <label><input name="storeNO" type="checkbox" value="R388">北京-三里屯</label>
                    <label><input name="storeNO" type="checkbox" value="R448">北京-王府井</label>
                    <label><input name="storeNO" type="checkbox" value="R479">北京-华贸购物中心</label>
                    <label><input name="storeNO" type="checkbox" value="R359">上海-南京东路</label>
                    <label><input name="storeNO" type="checkbox" value="R389">上海-浦东</label>
                    <label><input name="storeNO" type="checkbox" value="R390">上海-香港广场</label>
                    <label><input name="storeNO" type="checkbox" value="R401">上海-环贸 iapm</label>
                    <label><input name="storeNO" type="checkbox" value="R643">南京-虹悦城</label>
                    <label><input name="storeNO" type="checkbox" value="R637">天津-大悦城</label>
                    <label><input name="storeNO" type="checkbox" value="R502">成都-万象城</label>
                    <label><input name="storeNO" type="checkbox" value="R574">无锡-恒隆广场</label>
                    <label><input name="storeNO" type="checkbox" value="R471">杭州-西湖</label>
                    <label><input name="storeNO" type="checkbox" value="R532">杭州-万象城</label>
                    <label><input name="storeNO" type="checkbox" value="R534">沈阳-中街大悦城</label>
                    <label><input name="storeNO" type="checkbox" value="R484">深圳-益田假日广场</label>
                    <label><input name="storeNO" type="checkbox" value="R572">郑州-万象城</label>
                    <label><input name="storeNO" type="checkbox" value="R476">重庆-北城天街</label>
                    <label><input name="storeNO" type="checkbox" value="R480">重庆-解放碑</label>
                    <label><input name="storeNO" type="checkbox" value="R573">重庆-万象城</label>
                </div>
                <div id="hkStore">
                    <label><input name="storeNO" type="checkbox" value="R499">香港-CantonRoad</label>
                    <label><input name="storeNO" type="checkbox" value="R409">香港-CausewayBay</label>
                    <label><input name="storeNO" type="checkbox" value="R485">香港-FestivalWalk</label>
                    <label><input name="storeNO" type="checkbox" value="R428">香港-ifc mall</label>
                </div>
                <input type="button" class="btn btn-default" onclick="doSubmit(2)" value="提交">
            </form>
        </div>
    </div>
</div>
<a href="OnlineStatus.html">在线购买状态查看</a>
<a href="StoreStatus.html">AppleStore存货状态</a>
<a href="task.html">任务列表</a>
<script type="application/javascript">
    function doSubmit(type) {
        var subUrl;
        var formID;
        if (type === 1) {
            subUrl = "/addOnlineTask";
            formID = "#addOnlineTaskForm";
        } else if (type === 2) {
            subUrl = "/addStoreTask";
            formID = "#addStoreTaskForm";
        }

        $.ajax({
            cache: false,
            type: "POST",
            url: subUrl, //把表单数据发送到ajax.jsp
            data: $(formID).serialize(), //要发送的是ajaxFrm表单中的数据
            async: false,
            error: function () {
                alert("添加任务失败！");
            },
            success: function (data) {
                alert(data);
            }
        });
    }

    function switchStore() {
        var sl = document.getElementById("storeRegion");
        var op = sl.options[sl.selectedIndex].value;
        if ("cn" === op) {
            document.getElementById("cnStore").style.display = "";
            document.getElementById("hkStore").style.display = "none";
        }
        if ("hk" === op) {
            document.getElementById("hkStore").style.display = "";
            document.getElementById("cnStore").style.display = "none";
        }
        //清除已经选择的
        $("input[type=checkbox][name=storeNO]").each(function () {
            jQuery(this).attr("checked", false);
        });
    }
</script>
</body>
</html>
